package com.catersystem.zmy.catersystem.adapter;

import android.graphics.drawable.Drawable;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.TextView;

import com.catersystem.zmy.catersystem.R;
import com.catersystem.zmy.catersystem.bean.VoiceBean;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

/**
 * Created by Administrator on 2017/10/31 0031.
 */

public class DialogVoiceAdapter extends BaseQuickAdapter<VoiceBean, BaseViewHolder> {
    private int mPosition = 0;

    public DialogVoiceAdapter(@Nullable List<VoiceBean> data) {
        super(R.layout.rv_voice_select_dialog, data);
    }

    @Override
    protected void convert(BaseViewHolder holder, VoiceBean item) {
        holder.setText(R.id.tv_voice_name, item.getName());
        TextView tvVoiceName = holder.getView(R.id.tv_voice_name);
        Drawable drawable = mContext.getResources().getDrawable(R.mipmap.icon_yinxiao);
        drawable.setBounds(0, 0, drawable.getMinimumWidth(), drawable.getMinimumHeight());
        tvVoiceName.setCompoundDrawables(holder.getAdapterPosition() == 0 ? null : drawable, null, null, null);
        holder.setChecked(R.id.rb_voice_select, mPosition == holder.getAdapterPosition() ? true : false);
        holder.addOnClickListener(R.id.rb_voice_select);
    }

    public void setPosition(int position) {
        this.mPosition = position;
        notifyDataSetChanged();
    }
}
